import { Router } from "express";
import { CommentController } from "../controllers";
import { deserializeUser, requireLogin, validate } from "../middlewares";
import { commentSchema, updateCommentSchema } from "../schemas";

const router = Router();

router.post(
  "/",
  validate(commentSchema),
  deserializeUser,
  requireLogin,
  CommentController.create,
);
router.get("/", CommentController.findMany);
router.get("/:id", CommentController.findOne);
router.patch(
  "/:id",
  validate(updateCommentSchema),
  deserializeUser,
  requireLogin,
  CommentController.update,
);
router.delete("/:id", deserializeUser, requireLogin, CommentController.remove);

export { router as commentRouter };
